#ifndef __GTC_CLIENT_PAL_H__
#define __GTC_CLIENT_PAL_H__

#include "gtc_client_struct.h"
#include "platform.h"
#include "mod_can.h"
#include "dev.h"

/*******************************************
用户参数区，用户根据实际情况调整参数

*******************************************/


/********************************************************************************************
                     $$$$$$$$$$$$$$$$必选配置区$$$$$$$$$$$$$$$$

********************************************************************************************/


#define CHARGE_GUN_CNT                  2       //充电桩枪数量
#define MAX_HISTORY_ORDER_CNT	        (CHARGE_GUN_CNT * 2)	//最大保存账单数量 必须大于枪数量
#define GTC_GUN_TYPE                     gtc_gun_type_dc 
#define GTC_DEV_ID                      "0755201911270017"      //初始默认值 ，需调用xj_touch_set_equipment_id重新配置
#define GTC_SERVER_ADDR                 "47.96.7.231"           //中心服务器默认地址
#define GTC_SERVER_PORT                 8188                                //中心服务器默认端口
#define GTC_MQTT_USERNAME                "cdzdev"    
#define GTC_MQTT_PASSWORD                "gxcdz@0930"
#define GTC_MAC_ADDR                     "000000"                //初始默认值 ，需调用xj_touch_set_mac_addr重新配置 
#define USER_VERSION                    0x00010000
#define SOFT_VERSION                    "2.1.1.0"

/********************************************************************************************
                  @@@@@@@@@@@@@@可选调用区@@@@@@@@@@@@@@@

********************************************************************************************/
// extern void xj_pal_print_log(xj_log_type type, char* format, ... );

/*
刷卡鉴权报文
id 卡号
pwd 密码
type 充电类型
value 充电类型对应的值
*/
extern int32_t gtc_send_touch_card_start_charge(uint32_t gunnum, char_t *id, char_t *pwd, uint8_t type, uint32_t value);


/********************************************************************************************
                $$$$$$$$$$$$$$$$必选调用区$$$$$$$$$$$$$$$$

********************************************************************************************/
extern int32_t gtc_send_touch_charge_idle(uint32_t gun_cnt);
extern int32_t gtc_send_touch_charge_stoped(uint32_t gun_cnt, const char_t *stop_reason);
extern int32_t gtc_send_touch_error_occured(uint32_t gun_cnt, const char_t* err_no);
extern int32_t gtc_send_touch_error_recovered(uint32_t gun_cnt, const char_t* err_no);
extern int32_t gtc_touch_set_equipment_id(uint8_t* ID_str);
extern int32_t gtc_touch_set_mac_addr(uint8_t* mac_str);
extern int32_t gtc_charger_state_reup(uint32_t gun_id);



/********************************************************************************************
                  @@@@@@@@@@@@@@可选重定义区@@@@@@@@@@@@@@@

********************************************************************************************/



/********************************************************************************************
                    $$$$$$$$$$$$$$$$必选重定义区$$$$$$$$$$$$$$$$

********************************************************************************************/

uint32_t gtc_pal_time(void);
uint32_t gtc_pal_get_int_hour(void);
uint32_t gtc_pal_get_int_minute(void);
int32_t gtc_get_dev_type(void);
int8_t gtc_pal_write_persist_params(char* input,int32_t size);
int8_t gtc_pal_read_persist_params(char* output,int32_t limit);
int gtc_get_server_addr(char_t *addr, int32_t len);
int gtc_get_server_port(void);
int gtc_get_devid(char_t *id, int32_t len);
int pal_get_gun_cnt(void);

void get_kwh_zone_str(const uint16_t *kwh, char_t *str);
    
int32_t pal_save_history_bill(char_t *order_id);
int32_t pal_save_current_bill(struct GtcBillInfo *record);

void callback_start_charge(uint8_t gun_cnt,char* err);
void callback_stop_charge(uint8_t gun_cnt, char* err);
int8_t callback_read_bill(struct GtcHistroyBill *bill, uint32_t cnt);
int32_t callback_set_sys_time(uint32_t sec);
//void callback_software_download(xj_software_upgrade_type type,char* url,const char*check_md5,char*downl_md5);
int8_t callback_save_bill(char* bill,uint32_t size);
//int8_t callback_upload_log(const xj_upload_log_param* upload_url,char* log_name ,uint16_t max_len);
int32_t callback_card_ack(uint32_t gunnum, uint8_t ret);
int32_t callback_reboot_system(void);
int32_t callback_set_net_state(uint8_t state);
void calback_settle_set(uint8_t gun_id, uint32_t tcost);

int32_t callback_get_update_info(uint8_t *buf, uint32_t len);
int32_t callback_save_update_file(uint8_t *buf, uint32_t len);
int32_t callback_push_update_file_data(const char *name, int32_t pos, char_t *buf, int32_t len);

struct ClientUserGunInfo *pal_get_user_client_gun_data(void);
struct  ClientUserBmsInfo *pal_get_user_client_bms_data(void);
void pal_init(void);

#endif

